Attribute VB_Name = "随机模拟"

'统计某字符的数目
Function CountX(strInput As String, strFind As String) As Integer
    CountX = Len(strInput) - Len(Replace(strInput, strFind, ""))
End Function
'1为男，0为女
Function JSJXM(Optional ByVal xingbie As Byte = 2)

Dim xingming As String, xingshi As String, nanxingming As String, nvxingming As String

'避免重复调用影响运行时间，先进行读取
xingshi = DATA_xingshi
nanxingming = DATA_nanxingming
nvxingming = DATA_nvxingming

If xingbie = 1 Then
    xingming = Split(xingshi, ",")(Int(Rnd * CountX(xingshi, ",") + 1)) & _
    Split(nanxingming, ",")(Int(Rnd * CountX(nanxingming, ",") + 1))

ElseIf xingbie = 0 Then
    xingming = Split(xingshi, ",")(Int(Rnd * CountX(xingshi, ",") + 1)) & _
    Split(nvxingming, ",")(Int(Rnd * CountX(nvxingming, ",") + 1))

Else
    xingming = Split(xingshi, ",")(Int(Rnd * CountX(xingshi, ",") + 1)) & _
    Split(nanxingming & nvxingming, ",")(Int(Rnd * CountX(DATA_nanxingming & nvxingming, ",") + 1))
End If
JSJXM = xingming
End Function
